


******************************************************************************
*Bloomberg data
******************************************************************************

*************************
* Prices
*************************

import excel "../data/bloomberg/raw_data/bloomberg.xlsx", sheet("Prices") cellrange(A4) firstrow clear

*Rename the variables
rename *, lower
rename *index 	*
rename *yr 		*
rename *govt 	*
rename *curncy	*

drop if _n <= 2

*Format date
rename a date_help
gen date=date(date_help, "MDY")
format date %td
order date
drop date_help

*Convert to string
destring, replace ignore("#N/A N/A")

*************************
* Returns
*************************

preserve 
	import excel "../data/bloomberg/raw_data/bloomberg.xlsx", sheet("Returns") cellrange(A4) firstrow clear

	*Rename the variables
	rename *, lower
	rename spxindex spx_ret

	drop if _n <= 2

	*Format date
	rename a date_help
	gen date=date(date_help, "MDY")
	format date %td
	order date
	drop date_help

	*Convert to string
	destring, replace ignore("#N/A N/A")
	
	tempfile returns
	save	`returns'
restore 

********************************
**Merge Data
********************************
merge 1:1 date using `returns', nogen

**label variables
label variable usgg5 "On-the-run 5yr yield (BBG)"
label variable usgg10 "On-the-run 10yr yield (BBG)"
label variable usgg30 "On-the-run 30yr yield (BBG)"
label variable gtii10 "On-the-run 10yr TIPS (BBG)"
label variable gtii30 "On-the-run 30yr TIPS (BBG)"
label variable usswit10 "10yr inflation swap (BBG)"
label variable spx "S&P 500 Index (BBG)"
label variable move "Merrill Lynch Optional Volatility Estimate (MOVE) Index (BBG)"
label variable bcom "Bloomberg Commodity Index (BBG)"
label variable bcomag "Bloomberg Agriculture Subindex (BBG)"
label variable spx_ret "S&P 500 daily returns (BBG)"

compress 
save "../data/bloomberg/clean_data/bloomberg.dta", replace